#include <iostream>
#include <vector>
#include <set>

#include "Omega.h"
#include "Variable.h"
#include "Outcome.h"
#include "Preference.h"
#include "PreferenceSet.h"
#include "Constraint.h"
#include "functions.h"

using namespace std;

int main(){

    /***************************************************************************************/

    cout<<"/- TEST : Fonctionnement des classes -/"<<endl<<endl;

    /* VARIABLES */

    Variable v1("M",2,"fish","meat"); v1.show();

    Variable v3("W",2,"white","red"); v3.show();

    Variable v2("D",2,"cake","ice_cream"); v2.show(); cout<<endl;

    /* OMEGA */

    vector<Variable> vect; vect.push_back(v1); vect.push_back(v2); vect.push_back(v3);
    Omega o1(vect); o1.generateIndex();
    o1.showExtension(); cout<<endl;

    /* PREFERENCES */

    Preference p1( "fish" , "meat") ;
    Preference p2( "meat", "fish", "red" ) ;
    Preference p3( "cake", "ice_cream", "white" ) ;
    p1.setSemantic("CeterisParibus"); p2.setSemantic("CeterisParibus"); p3.setSemantic("Strong");
    p1.show(); p2.show(); p3.show();

    /* PREFERENCE SET */
    PreferenceSet ps;
    ps.addPreference(p1);
    ps.addPreference(p2);
    ps.addPreference(p3);
    cout<<endl;

    /* CONSTRAINTS */

    set<int> omega; generateIndex(o1,omega);
    vector<Constraint> constraints;
    constraints = generateConstraints(omega,ps,o1);
    for(int i(0);i<(int)constraints.size();++i){
        constraints[i].show();
    }

     cout<<"/- FIN TEST -/"<<endl<<endl;

     /***************************************************************************************/

     /***************************************************************************************/

     cout<<"/- TEST : Calcul de preferences -/"<<endl<<endl;

     vector< vector<int> > res = scpo(ps,o1);
     for(int i = 0;i<(int)res.size();i++)
     {
         cout<<"E["<<i+1<<"] = {"<<endl;

         for(int j=0;j<(int)res[i].size();j++)
         {
             o1.generateOutcome(res[i][j]).show();
         }
         cout<<"}"<<endl;
     }

     cout<<"/- FIN TEST -/"<<endl<<endl;

     /***************************************************************************************/

    /***************************************************************************************/

    cout<<"/- TEST : Construction d'Outcomes sur des variables de plus de 10 valeurs -/"<<endl<<endl;

    Variable var_numbers("v1",12,"1","2","3","4","5","6","7","8","9","10","11","12"); var_numbers.show();
    Variable var_letters("v2",11,"a","b","c","d","e","f","g","h","i","j","k"); var_letters.show(); cout<<endl;

    vect.clear(); vect.push_back(var_numbers); vect.push_back(var_letters);
    Omega o2(vect); o2.generateIndex();

    cout<<"Voulez-vous afficher omega ? ("<<o2.getActualSize()<<" valeurs) o/n : ";
    char c; cin>>c;

    if(c=='o') o2.showExtension();

     cout<<"/- FIN TEST -/"<<endl<<endl;

     /***************************************************************************************/


return 0;
}

